# 构建Jenkins编译环境镜像
# 环境包括JDK v1.8、Maven v3.9.6、Node v18.20、docker、kubectl
# docker启动需要挂在宿主机docker.sock  eg: -v /var/run/docker.sock:/var/run/docker.sock
# kubectl启动需要挂着k8s证书文件       eg: -v /root/.kube/config:/root/.kube/config

FROM centos:7

ADD apache-maven-3.9.6-bin.tar.gz /usr/local/
ADD node-v16.20.2-linux-x64.tar.xz /usr/local/

# docker、kubectl工具集成方法
# 1. 集群中直接把工具添加镜像中
# ADD /usr/local/bin/kubectl /usr/local/bin
# ADD /usr/bin/docker /usr/local/bin
# 2. 挂载集群中文件到镜像 
# -v /usr/local/bin/kubectl:/usr/local/bin
# -v /usr/bin/docker:/usr/local/bin

RUN ln -s /usr/local/apache-maven-3.9.6/bin/mvn /usr/local/bin/mvn \
    && ln -s /usr/local/node-v16.20.2-linux-x64/bin/node /usr/local/bin/node \
    && ln -s /usr/local/node-v16.20.2-linux-x64/bin/npm /usr/local/bin/npm \
    && yum install -y java-1.8.0-openjdk-devel git \
    && yum clean all \
    && npm config set registry https://registry.npmmirror.com
